<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <link href="/styles/base.css" rel="stylesheet" type="text/css">
    <link href="/styles/addtravelnote.css" rel="stylesheet" type="text/css">
    <link href="/js/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    <link href="/js/plugins/datepicker/datepicker.css" rel="stylesheet">
    <script type="text/javascript" src="/js/jquery/jquery.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.min.js"></script>
    <script type="text/javascript" src="/js/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="/js/plugins/datepicker/datepicker.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>

    <link href="/js/plugins/chosen/chosen.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/plugins/chosen/chosen.jquery.js"></script>
    <script type="text/javascript" src="/js/system/common.js"></script>
    <script type="text/javascript" src="/js/system/addqaanote.js"></script>
    <script>
        $(function () {
            $(".chose_pic").click(function () {
                $("#coverBtn").click();
            })
            $("#coverBtn").change(function () {
                if (this.value) {
                    $("#coverForm").ajaxSubmit(function (data) {
                        $(".choseBtn").html(" + 重新选择");
                        $("#coverImage").attr("src", "/" + data);
                        $("#coverValue").val("/" + data);
                    })
                }
            })

            //保存或发表
            $(".btn_submit").click(function () {
                $("#state").val($(this).data("state"));
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success) {
                        window.location.href = "/qanda/detail?id=" + data.data
                    } else {
                        popup("操作失败");
                    }
                })
            })

            //目的地
            $("#region").chosen();


            //内容回显
            if ('${qaa!}') {
                ue.setContent('${(qaa.questionAndAnswerContent.content)!}');
            }
        })
    </script>
</head>


<body>
<#assign currentNav="community">
<#include "../common/navbar.ftl">

<!--文件上传-->
<form action="/qanda/coverImageUpload" method="post" id="coverForm">
    <input type="file" name="pic" id="coverBtn" style="display: none;">
</form>


<div class="wrapper">
    <#--<div class="ap-head">
        <h1>发表新话题/文章</h1>
        <div class="clearfix"></div>
    </div>-->
    <br>
    <div class="crumb" style="font-size: 24px">
        <a href="list/">旅游问答</a> &gt; <span>我要提问</span>
    </div>
    <div class="ap-wrap">
        <div class="ap-main">
            <form class="forms" action="/qanda/saveOrUpdate" method="post" id="editForm">
                <input type="hidden" name="id" value="${(qaa.id)!}">
                <input type="hidden" name="state" id="state">


                <dl class="title cf">
                    <dd>
                        <label class="" style="display: block;">请在这里输入提问标题,最少10个字</label>
                        <span class="char-limit _j_char_limit hide">可输入<strong>48</strong>字</span>
                        <input id="title" name="title" type="text" maxlength="48" value="${(qaa.title)!}">
                    </dd>
                </dl>
                <dl>
                    <dd>
                        <div class="chose_pic">
                            <img src="${(qaa.coverUrl)!}" id="coverImage"><span class="choseBtn">+ 选择封面</span>
                            <input type="hidden" name="coverUrl" id="coverValue" value="${(qaa.coverUrl)!}">
                        </div>
                    </dd>
                </dl>
                <dl>
                    <div class="pi-base">
                        <div class="pi-row">


                            <div class="pi-col pi-date" style="margin-left: 2%;"><label for="isopen">是否公开</label>
                                <input class="pi-input" style="margin-top: 13px;width:15px; height: 15px;"
                                       name="isPublic" value="1"
                                       type="checkbox" id="isopen"/>

                                <script>
                                    $("#isopen").attr("checked", ${((qaa.isPublic)?c)!})
                                </script>


                            </div>
                        </div>
                        <div class="pi-row">

                            <div class="pi-col pi-date" style="margin-left: 2%;"><label for="isopen">旅游地点</label>
                                <div class="pi-dropdown " style="text-align: left">
                                    <select name="dest.id" data-placeholder="请选择目的地" id="region" style="width: 150px;">
                                        <#list regions as r>
                                            <option value="${r.id!}">${r.name!}</option>
                                        </#list>
                                    </select>

                                    <script>
                                        $("#region").val(${(qaa.dest.id)!});
                                    </script>
                                </div>
                            </div>
                        </div>
                    </div>
                </dl>
                <dl class="body cf">
                    <dd id="content_div">
                        <script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
                    </dd>
                </dl>
                <div class="btns">
                    <div class="accept_pact">
                        <input type="checkbox" checked="">
                        我已阅读并同意<a href="javascript:;" title="《骡窝窝游记协议》" target="_blank">《骡窝窝游记协议》</a>
                    </div>
                    <input class="btn_submit" value="提问" type="button" data-state="1">

                </div>
            </form>
        </div>
    </div>
</div>
<#include "../common/footer.ftl">
</body>

</html>